package gui;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Color;
import java.awt.GridBagLayout;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.awt.Font;
import java.sql.SQLException;

import com.sun.rowset.CachedRowSetImpl;

import flexibility.CachedRowSetTableModel;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.table.DefaultTableModel;
import java.awt.event.InputMethodListener;
import java.awt.event.InputMethodEvent;

public class ManagementAssignmentsGUI extends JPanel{
	public JTable table;
	public JScrollPane scrollPane;
	public JLabel lblThereAreNo;
	private JLabel lblListOfExisting;
	public JButton btnReturn;
	public JButton btnAddAssignment;
	public JButton btnUploadNewAssignment;
	private JLabel lblCourseid;
	public JLabel lblCid;
	public JButton btnNewButton;
	public String cid;
	
	public ManagementAssignmentsGUI() {
			super();
			initialize();
	
	}
	private void initialize() {
		this.setSize(900,600);
		this.setBackground(UIManager.getColor("InternalFrame.activeTitleBackground"));
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		
		JPanel panel = new JPanel();
		panel.setBackground(UIManager.getColor("InternalFrame.activeTitleBackground"));
		panel.setToolTipText("");
		springLayout.putConstraint(SpringLayout.NORTH, panel, 24, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, panel, 31, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.SOUTH, panel, 571, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.EAST, panel, 863, SpringLayout.WEST, this);
		add(panel);
		SpringLayout sl_panel = new SpringLayout();
		panel.setLayout(sl_panel);
		
		table = new JTable();
		
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null},
			},
			new String[] {
				"New column", "New column", "New column", "New column"
			}
		));
		
		
		scrollPane = new JScrollPane(table);
		sl_panel.putConstraint(SpringLayout.NORTH, scrollPane, 145, SpringLayout.NORTH, panel);
		sl_panel.putConstraint(SpringLayout.SOUTH, scrollPane, 275, SpringLayout.NORTH, panel);
		sl_panel.putConstraint(SpringLayout.EAST, scrollPane, 554, SpringLayout.WEST, panel);
		panel.add(scrollPane);
		
		lblThereAreNo = new JLabel("There are no assignments for this course");
		lblThereAreNo.setIcon(new ImageIcon(ManagementAssignmentsGUI.class.getResource("/com/sun/java/swing/plaf/windows/icons/Warn.gif")));
		lblThereAreNo.setFont(new Font("Tahoma", Font.PLAIN, 14));
		sl_panel.putConstraint(SpringLayout.WEST, lblThereAreNo, 0, SpringLayout.WEST, scrollPane);
		lblThereAreNo.setForeground(Color.RED);
		lblThereAreNo.setVisible(false);
		panel.add(lblThereAreNo);
		
		lblListOfExisting = new JLabel("List of existing assignments in this course:");
		lblListOfExisting.setFont(new Font("Tahoma", Font.BOLD, 15));
		sl_panel.putConstraint(SpringLayout.SOUTH, lblListOfExisting, -24, SpringLayout.NORTH, scrollPane);
		sl_panel.putConstraint(SpringLayout.WEST, scrollPane, 0, SpringLayout.WEST, lblListOfExisting);
		sl_panel.putConstraint(SpringLayout.WEST, lblListOfExisting, 147, SpringLayout.WEST, panel);
		panel.add(lblListOfExisting);
		
		btnReturn = new JButton("return");
		sl_panel.putConstraint(SpringLayout.NORTH, btnReturn, 371, SpringLayout.NORTH, panel);
		sl_panel.putConstraint(SpringLayout.WEST, btnReturn, 81, SpringLayout.WEST, panel);
		sl_panel.putConstraint(SpringLayout.SOUTH, lblThereAreNo, -23, SpringLayout.NORTH, btnReturn);
		btnReturn.setFont(new Font("Tahoma", Font.BOLD, 13));
		panel.add(btnReturn);
		
		btnAddAssignment = new JButton("add assignment");
		btnAddAssignment.setFont(new Font("Tahoma", Font.BOLD, 14));
		sl_panel.putConstraint(SpringLayout.WEST, btnAddAssignment, 40, SpringLayout.EAST, scrollPane);
		
		btnAddAssignment.setToolTipText("Add task in previous semesters\r\nAssociated with this course");
		panel.add(btnAddAssignment);
		
		btnUploadNewAssignment = new JButton("upload new assignment");
		btnUploadNewAssignment.setFont(new Font("Tahoma", Font.BOLD, 14));
		sl_panel.putConstraint(SpringLayout.SOUTH, btnAddAssignment, -28, SpringLayout.NORTH, btnUploadNewAssignment);
		sl_panel.putConstraint(SpringLayout.EAST, btnAddAssignment, 0, SpringLayout.EAST, btnUploadNewAssignment);
		sl_panel.putConstraint(SpringLayout.WEST, btnUploadNewAssignment, 40, SpringLayout.EAST, scrollPane);
		
		btnUploadNewAssignment.setToolTipText("Upload files that are in your computer");
		panel.add(btnUploadNewAssignment);
		
		lblCourseid = new JLabel("courseID:");
		lblCourseid.setForeground(Color.BLUE);
		sl_panel.putConstraint(SpringLayout.NORTH, lblCourseid, 23, SpringLayout.NORTH, panel);
		sl_panel.putConstraint(SpringLayout.WEST, lblCourseid, 27, SpringLayout.WEST, panel);
		panel.add(lblCourseid);
		
		lblCid = new JLabel("cid");
		lblCid.setForeground(Color.BLUE);
		sl_panel.putConstraint(SpringLayout.NORTH, lblCid, 23, SpringLayout.NORTH, panel);
		sl_panel.putConstraint(SpringLayout.WEST, lblCid, 50, SpringLayout.EAST, lblCourseid);
		sl_panel.putConstraint(SpringLayout.EAST, lblCid, 105, SpringLayout.EAST, lblCourseid);
		panel.add(lblCid);
		
		btnNewButton = new JButton("Refresh Assignments Table");
		btnNewButton.setFont(new Font("Tahoma", Font.BOLD, 14));
		
		sl_panel.putConstraint(SpringLayout.NORTH, btnNewButton, 248, SpringLayout.NORTH, panel);
		sl_panel.putConstraint(SpringLayout.WEST, btnNewButton, 40, SpringLayout.EAST, scrollPane);
		sl_panel.putConstraint(SpringLayout.SOUTH, btnUploadNewAssignment, -25, SpringLayout.NORTH, btnNewButton);
		sl_panel.putConstraint(SpringLayout.EAST, btnUploadNewAssignment, 0, SpringLayout.EAST, btnNewButton);
		panel.add(btnNewButton);
	}
}
